<%@ page import="com.wuming.caiwu.security.SecurityHander" %><%--
  Created by IntelliJ IDEA.
  User: hanfei
  Date: 18/6/27
  Time: 下午3:45
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${allServerPath}static/css/bootstrap.min.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/style.css">
    <link rel="stylesheet" href="${allServerPath}static/layui/css/public.css">
    <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->

    <style>
        .tab_zp td span {
            font-weight: bold;
            color: #003399;
        }

        ::-moz-placeholder {
            color: #d4d4d4;
        }

        ::-webkit-input-placeholder {
            color: #d4d4d4;
        }

        :-ms-input-placeholder {
            color: #d4d4d4;
        }

        .zptip {
            cursor: pointer;
        }

    </style>
</head>
<body>
<div style="padding: 15px;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>学员基本信息</legend>
    </fieldset>

    <form class="layui-form" action="" id="studentForm">
        <OBJECT classid="clsid:10946843-7507-44FE-ACE8-2B3483D179B7"
                id="CVR_IDCard" name="CVR_IDCard" width="0" height="0">
        </OBJECT>
        <div class="layui-row">
            <div class="layui-col-md6">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">准驾车型</label>

                        <div class="form-group layui-input-inline">
                            <select id="admitCarType" name="admitCarType" lay-filter="admitCarType">
                                <option value=""></option>
                                <option value="C1">C1</option>
                                <option value="C2">C2</option>
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">申请类型</label>

                        <div class="form-group layui-input-inline">
                            <select id="businessType" name="businessType" lay-filter="businessType">
                                <option value=""></option>
                                <option value="初次申领">初次申领</option>
                                <option value="增驾">增驾</option>
                            </select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">证件号码</label>

                        <div class="form-group layui-input-inline" style="width: 450px;">
                            <input type="text" name="certNo" placeholder="" autocomplete="off"
                                   class="layui-input" style="width: 50%;display: inline-block"
                                   value="${student['certNo']}">
                            <%--<button type="button" class="layui-btn" id="btnUploadIDCard">选择图片
                            </button>--%>
                        </div>
                    </div>

                </div>
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <label class="layui-form-label">出生年月</label>

                        <div class="form-group layui-input-inline">
                            <input type="text" name="birthday" value="${student['birthday']}" id="birthday"
                                   autocomplete="off" class="layui-input">
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-row">

            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">姓名</label>

                    <div class="form-group layui-input-inline">
                        <input type="text" name="studentName" value="${student['studentName']}" placeholder="请输入姓名"
                               autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>


            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">手机号</label>

                    <div class="form-group layui-input-inline">
                        <input type="text" name="mobile" value="${student['mobile']}" placeholder="请输入手机号"
                               autocomplete="off" class="layui-input">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">报名日期</label>

                    <div class="form-group layui-input-inline">
                        <input type="text" name="signDate" id="signDate" value="${student['signDate']}" autocomplete="off"
                               class="layui-input">
                    </div>
                </div>
            </div>
        </div>
        <input type="hidden" name="id" value="${student['id']}"/>
        <%--<input type="hidden" name="studentUid" value="${student['studentUid']}"/>--%>
        <input type="hidden" name="memberId" value="<%=SecurityHander.getCurrentUserId()%>"/>
    </form>
    <div class="layui-row">
        <div class="layui-col-md12">
            <div class="layui-form-item">
                <button class="layui-btn" type="button" name="btnSave" id="btnSave" lay-filter="student">保存学员信息
                </button>
            </div>
        </div>
    </div>

</div>

<script src="${allServerPath}static/layui/layui/layui.js" charset="utf-8"></script>
<script src="${allServerPath}static/js/jquery-2.1.4.min.js" charset="utf-8"></script>
<script src="${allServerPath}static/js/bootstrap.min.js" charset="utf-8"></script>
<script type="text/javascript" src="${allServerPath}static/js/bootstrapValidator.js"></script>
<script type="text/javascript" src="${allServerPath}static/js/common/date-util.js"></script>
<script type="text/javascript"
        src="${allServerPath}static/js/common/jiaoguan-util.js?t=<%=System.currentTimeMillis()%>"></script>
<script type="text/javascript" src="${allServerPath}static/js/common.js"></script>
<script type="text/javascript" src="${allServerPath}static/js/common/IA300ClientJavascript.js"></script>
<%--<script type="text/javascript" src="${allServerPath}static/js/mToken_K1.js"></script>--%>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    layui.use(['layer', 'form', 'laydate', 'jquery', 'upload'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate
            , $ = layui.jquery
            , upload = layui.upload;


        //日期
        laydate.render({
            elem: '#birthday'
        });

        laydate.render({
            elem: '#signDate'
        });

        upload.render({
            elem: '#btnUploadIDCard' //绑定元素
            , url: '${allServerPath}web/student/uploadIDCard.htmls' //上传接口
            , done: function (res) {
                //上传完毕回调
                console.log("suc");
            }
            , error: function () {
                //请求异常回调
                console.log("fal");
            }
        })

        var admitCarType = '${student.admitCarType}';
        if ('' == admitCarType) {
            $("#admitCarType").find("option[value='C1']").attr("selected", true);
        } else {
            $("#admitCarType").val(admitCarType);
        }


        var businessType = '${student.businessType}';
        if ('' == businessType) {
            $("#businessType").find("option[value='初次申领']").attr("selected", true);
        } else {
            $("#businessType").val(businessType);
        }
        form.render();


        $("button[name='btnSave']").click(function () {
            $("#studentForm").data("bootstrapValidator").resetForm();
            $("#studentForm").bootstrapValidator('validate');
            if ($("#studentForm").data('bootstrapValidator').isValid()) {
                $.ajax({
                    type: 'post',
                    url: '${allServerPath}web/student/save.htmls',
                    data: $("#studentForm").serialize(),
                    dataType: 'JSON',
                    success: function (data) {
                        if (data.success) {
                            $("input[name='id']").val(data.data);
                            layer.msg("保存成功.");
                        } else {
                            layer.msg(data.message);
                        }
                    },
                    error: function () {
                        layer.msg("保存失败.");
                    }
                });
            }
        });

        $('#studentForm')
            .bootstrapValidator({
                live: 'disabled',//验证时机
                message: 'This value is not valid',
                submitButtons: '#btnSave',//指定提交按钮
                feedbackIcons: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    studentName: {
                        validators: {
                            notEmpty: {
                                message: '不能为空'
                            }
                        }
                    },
                    certNo: {
                        validators: {
                            notEmpty: {
                                message: '不能为空'
                            },
                            stringLength: {
                                min: 15,
                                max: 18,
                                message: '请输入正确身份证号'
                            },
                            regexp: {
                                regexp: /^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$/,
                                message: '请输入正确身份证号'
                            }
                        }
                    },
                    mobile: {
                        validators: {
                            notEmpty: {
                                message: '不能为空'
                            },
                            stringLength: {
                                min: 11,
                                max: 11,
                                message: '请输入正确手机号码'
                            },
                            regexp: {
                                regexp: /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/,
                                message: '请输入正确手机号码'
                            }
                        }
                    },
                }
            });
    });
</script>
</body>
</html>
